﻿using UnityEngine;

/// <summary>
/// 设置多屏全屏
/// </summary>
public class HScreenSet : MonoBehaviour
{
    public GameObject background;
    private void OnEnable()
    {
#if UNITY_EDITOR
        Cursor.visible = true;
#else
        Cursor.visible = false;
        if(background!=null){
            background.SetActive(false);
        }
#endif

        for (int i = 0; i < Display.displays.Length; i++)
        {
            Display.displays[i].Activate();
            Screen.SetResolution(Display.displays[i].renderingWidth, Display.displays[i].renderingHeight, true);
        }

        //Resolution[] resolutions = Screen.resolutions;//获取设置当前屏幕分辩率
        //Screen.SetResolution(resolutions[resolutions.Length - 1].width, resolutions[resolutions.Length - 1].height, true);//设置显示器最大分辨率

        Screen.fullScreen = true;  //设置成全屏
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.F8))
        {
            if (background != null)
            {
                background.SetActive(!background.activeSelf);
            }
        }
    }
}
